//
//  PreGoods.swift
//  mosdks
//
//  Created by zhuxietong on 2020/9/4.
//

import Foundation
import soapp
import Eelay
import AsyncDisplayKit

open class PrebuyTipKit: MoDisplayNode {
    public let label1 = ASTextNode2()
    public let label2 = ASTextNode2()
    public let label3 = ASTextNode2()
    
    public let back = ASDisplayNode()
    
    
    open override func addLayoutRules() {
        back.bsui.background(color: .color(light: "#000C4611", dark: "#FFFFFF22")).set(radius: 12, width: nil, color: nil)
        label1.attributedText = "提示".ui.font13.color(color: ._foreground).astring
        label2.attributedText = "该商品为预购商品，支付订单后发货时间会有延后，请关注以下发货时间".ui.font12.color(color: ._foregroundWeak).astring
        label2.maximumNumberOfLines = 5
        label3.attributedText = "预计发货时间：2020-10-20".ui.font(font: .systemFont(ofSize: 15.co)).color(color: ._tint).astring

//        back.alpha = 0.06
    }
    
    open override func mo_model_reload() {
        label1.attributedText = "提示".ui.font13.color(color: ._foreground).astring
        label2.attributedText = "该商品为预购商品，发货时间会有延后".ui.font13.lineSpace(4).color(color: ._foregroundWeak).astring
//        label3.attributedText = "预计发货时间：2020-10-20".ui.bfont15.color(color: ._tint).astring
        
        let date = stampToTime(mo.model["presell.presellsendstatrttime",""])
        
        
        label3.attributedText = "预计发货时间  ".ui.font12.color(color: ._tint).astring + date["YYYY-MM-dd"].ui.bfont15.color(color: ._tint).astring

//        let time = Data(string)
        
    }
    
    open override func specGetter() -> _Spec {
//        let spec = _Spec.inset([], [15], child: [
            let spec = _Spec.stack(["h|30",[15]], childs: [
                label1[_grow(0),_shrink(0)],
                .stack(["v|18",_grow(1),_shrink(1),&-.stretch], childs: [
                    label2.Spec,
                    label3.Spec
                ])
            ])
//        ])
        return spec.addBack(back.Spec)
    }
    
}
